home *** CD-ROM | disk | FTP | other *** search
/ Interactive CD-ROM & Web Magazine 6 / Interactive CD-ROM & Web Magazine 6.iso / mac / INTERACTIVE MAC / SHARED.DIR / 05128.ls < prev    next >
Encoding:
Text File  |  1996-04-05  |  6.5 KB  |  222 lines

  1. global netscapeHandle, iswin95, hd, netObj, gResult, gDDELastErr, currentNetHandler, winId, winsockHandle, tobeonline, sockautolog, curElapsed, netscapePath
  2.  
  3. on URLClicked theURL
  4.   netObj(mInit)
  5.   if tobeonline = 1 then
  6.     if currentNetHandler <> "NetFeedback()" then
  7.       if not IsNetscapePresent(120) then
  8.         if not iswin95 then
  9.           if not launchwinsock() then
  10.             return 
  11.           end if
  12.         end if
  13.         if not launchNetscape() then
  14.           return 
  15.         end if
  16.       end if
  17.     end if
  18.     OpenURL(theURL)
  19.   else
  20.     put theURL into field 4002
  21.     copyToClipBoard(cast 4002)
  22.     alert("Hai scelto di non andare online. L'URL ├ï stato copiato negli appunti")
  23.   end if
  24. end
  25.  
  26. on launchwinsock
  27.   set winsockpath to GetConfigHelper("application", "winsock", hd & "mime.cfg")
  28.   if (winsockpath = EMPTY) or not netObj(mFileExist, winsockpath) then
  29.     set winsockpath to localizeWinsock()
  30.   end if
  31.   if winsockpath = EMPTY then
  32.     return 0
  33.   end if
  34.   set winsockHandle to netObj(mLaunch, winsockpath)
  35.   put winsockHandle
  36.   if (winsockHandle <= 32) and (winsockHandle <> 16) and (winsockHandle <> 8) then
  37.     alert("Non e' stato possibile lanciare il Winsock.")
  38.     return 0
  39.   end if
  40.   if sockautolog then
  41.     netObj(mMinimizeInstance, winsockHandle)
  42.   end if
  43.   return 1
  44. end
  45.  
  46. on localizeWinsock
  47.   set winsockpath to AskApplication("Per favore trova l'applicazione Winsock.", "Applicazione Winsock")
  48.   if winsockpath <> EMPTY then
  49.     AddHelper("application", "winsock", winsockpath, hd & "mime.cfg")
  50.   end if
  51.   return winsockpath
  52. end
  53.  
  54. on AskApplication alertString, caption
  55.   alert(alertString)
  56.   return netObj(mGetPath, caption, "Applicazioni", "*.EXE")
  57. end
  58.  
  59. on launchNetscape
  60.   set netscapePath to GetConfigHelper("application", "netscape", hd & "mime.cfg")
  61.   if (netscapePath = EMPTY) or not netObj(mFileExist, netscapePath) then
  62.     set netscapePath to LocalizeNetscape()
  63.   end if
  64.   if netscapePath = EMPTY then
  65.     return 0
  66.   end if
  67.   set netscapeHandle to netObj(mLaunch, netscapePath)
  68.   if (netscapeHandle <= 32) and (netscapeHandle <> 16) and (netscapeHandle <> 16) then
  69.     alert("Non e' stato possibile lanciare Netscape.")
  70.     return 0
  71.   end if
  72.   return 1
  73. end
  74.  
  75. on LocalizeNetscape
  76.   set netscapePath to netObj(mRegPath, "NetscapeMarkup\shell\open")
  77.   set netscapePath to char 1 to length(netscapePath) - 3 of netscapePath
  78.   if (netscapePath = EMPTY) or not netObj(mFileExist, netscapePath) then
  79.     set netscapePath to AskApplication("Per favore trova Netscape Navigator", "Netscape Navigator")
  80.   end if
  81.   if netscapePath <> EMPTY then
  82.     AddHelper("application", "netscape", netscapePath, hd & "mime.cfg")
  83.   end if
  84.   return netscapePath
  85. end
  86.  
  87. on WaitConnection theTimeout, theURL
  88.   if the timer > theTimeout then
  89.     set currentNetHandler to EMPTY
  90.     alert("Non ├ï stato possibile attivare la comunicazione con Netscape Navigator. Riprova!")
  91.     return 
  92.   end if
  93.   set winId to netObj(mGetWinId, 1, 120)
  94.   if gDDELastErr <> "0" then
  95.     return 
  96.   end if
  97.   netObj(mTR_Start, 1, theURL, EMPTY, winId, 2, 3000)
  98.   if gDDELastErr <> "0" then
  99.     DDEError("Errore di comunicazione con Netscape Navigator.")
  100.     return 
  101.   end if
  102.   netObj(mTR_Start, 1, theURL, EMPTY, winId, 2, 3000)
  103.   if gDDELastErr <> "0" then
  104.     DDEError("Errore di comunicazione con Netscape Navigator.")
  105.     return 
  106.   end if
  107.   netObj(mRegURLEcho, 3000)
  108.   if gDDELastErr <> "0" then
  109.     DDEError("Errore di comunicazione con Netscape Navigator.")
  110.     return 
  111.   end if
  112.   set currentNetHandler to "NetFeedback()"
  113.   netObj(mActivate, winId, 3000)
  114. end
  115.  
  116. on OpenURL theURL
  117.   startTimer()
  118.   set currentNetHandler to "WaitConnection(60*60*2, " & numToChar(34) & theURL & numToChar(34) & ")"
  119.   put currentNetHandler
  120. end
  121.  
  122. on IsNetscapePresent theTimeout
  123.   netObj(mGetNumWin, theTimeout)
  124.   if gDDELastErr <> "0" then
  125.     return 0
  126.   end if
  127.   return 1
  128. end
  129.  
  130. on DDEError theErrorAlert
  131.   alert(theErrorAlert & " [DDE Error: " & gDDELastErr & "]")
  132. end
  133.  
  134. on IsDocument theURL
  135.   set URLLength to length(theURL)
  136.   set position to 0
  137.   repeat with index = 0 to URLLength - 1
  138.     set curChar to char URLLength - index of theURL
  139.     if curChar = "." then
  140.       set position to URLLength - index + 1
  141.       exit repeat
  142.     end if
  143.   end repeat
  144.   if position > 0 then
  145.     if (char position to position + 2 of theURL = "htm") or (char URLLength - 1 of theURL = "/") then
  146.       return 1
  147.     else
  148.       return 0
  149.     end if
  150.   end if
  151. end
  152.  
  153. on ExtractWindowTitle theWindowInfo
  154.   set netscID to "Netscape - ["
  155.   set position to offset(netscID, theWindowInfo)
  156.   if position = 0 then
  157.     return EMPTY
  158.   end if
  159.   return char position + length(netscID) to length(theWindowInfo) - 2 of theWindowInfo
  160. end
  161.  
  162. on NetFeedback
  163.   if not IsNetscapePresent(120) then
  164.     if gDDELastErr <> "4002" then
  165.       alert("La comunicazione con Netscape Navigator si e' interrotta inaspettatamente.")
  166.       set currentNetHandler to EMPTY
  167.       set the text of field "URLFeedback" to EMPTY
  168.       set the text of field "TitleFeedback" to EMPTY
  169.       return 
  170.     end if
  171.   end if
  172.   set curURL to netObj(mTR_GetLastURL, 1, 3000)
  173.   if IsDocument(curURL) and (curURL <> the text of field "URLFeedback") then
  174.     set the text of field "URLFeedback" to curURL
  175.     set the text of field "TitleFeedback" to ExtractWindowTitle(netObj(mGetWinInfo, winId, 3000))
  176.   end if
  177. end
  178.  
  179. on CloseNetscape
  180.   netObj(mQuit, 3000)
  181.   if value(gResult) then
  182.     Obj(mQuitInstance, netscapeHandle)
  183.   end if
  184.   if not iswin95 then
  185.     Obj(mQuitInstance, winsockHandle)
  186.   end if
  187. end
  188.  
  189. on OpenDN theDNPath
  190.   if IsNetscapePresent(120) then
  191.     OpenURL(theDNPath)
  192.     return 
  193.   end if
  194.   set browserPath to GetConfigHelper("application", "browser", hd & "mime.cfg")
  195.   if (browserPath = EMPTY) or not netObj(mFileExist, browserPath) then
  196.     set browserPath to LocalizeBrowser()
  197.   end if
  198.   if browserPath = EMPTY then
  199.     return 
  200.   end if
  201.   open(theDNPath, browserPath)
  202. end
  203.  
  204. on LocalizeBrowser
  205.   set browserPath to GetConfigHelper("application", "netscape", hd & "mime.cfg")
  206.   if (browserPath <> EMPTY) and netObj(mFileExist, browserPath) then
  207.     return browserPath
  208.   end if
  209.   set browserPath to netObj(mRegPath, "NetscapeMarkup\shell\open")
  210.   set browserPath to char 1 to length(browserPath) - 3 of browserPath
  211.   if (browserPath <> EMPTY) and netObj(mFileExist, browserPath) then
  212.     return browserPath
  213.   end if
  214.   set alertString to "Questo articolo ├ï in HTML." & RETURN
  215.   set alertString to alertString & "Per favore trova il tuo browser HTML"
  216.   set browserPath to AskApplication(alertString, "Browser HTML")
  217.   if browserPath <> EMPTY then
  218.     AddHelper("application", "browser", browserPath, hd & "mime.cfg")
  219.   end if
  220.   return browserPath
  221. end
  222.